import { createStore } from 'vuex'

export default createStore({
  state: {
    editableTabsValue: '/index',
    editableTabs: [
      {
        title: '首页',
        name: '/index',
      },
    ],
  },
  getters: {},
  mutations: {
    ADD_TABS: (state, tab) => {
      if (state.editableTabs.findIndex((e) => e.name === tab.path) === -1) {
        state.editableTabs.push({
          title: tab.name,
          name: tab.path,
        })
      }
      state.editableTabsValue = tab.path
    },
    RESET_TAB: (state) => {
      state.editableTabsValue = '/index'
      state.editableTabs = [
        {
          title: '首页',
          name: '/index',
        },
      ]
    },
    // 这里可以添加逻辑判断，如果是添加about相关内容，做特定处理
    // if (tab.path === '/about') {
    //   tab.title = '关于',
    //   name: '/about'
    // }
  },
  actions: {},
  modules: {},
})
